package leetcode_1201_1300;

public class LeeCode_1269 {
    public static void main(String[] args) {
        System.out.println(numWays(4, 2));
    }
    private static int numWays(int steps, int arrLen) {
        long mod = (long) (1e9 + 7);
        int len = Math.min(arrLen, steps / 2 + 1);
        long[][] dp = new long[len][steps + 1];
        dp[0][0] = 1;
        for (int j = 1; j <= steps; j++) {
            for (int i = 0; i < dp.length; i++) {
                if (i > j)
                    continue;
                if (i - 1 >= 0)
                    dp[i][j] += dp[i - 1][j - 1];
                if (i + 1 < dp.length)
                    dp[i][j] += dp[i + 1][j - 1];
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= mod;
            }
        }
        return (int) dp[0][steps];
    }
}